﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Login.aspx.cs" Inherits="SH.STD.Web.Login" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>用户登录-科技处信息管理系统-公安部上海消防研究所</title>
    <link rel="Stylesheet" type="text/css" href="Styles/PTThemes.css" />
    <script type="text/javascript" src="Scripts/jquery-1.8.1.js"></script>
    <script type="text/javascript">
        function checkForm() {
            if ($("#username").val() == "") {
                $("#username").focus();
                alert("请填写用户名");
                return false;
            }
            if ($("#password").val() == "") {
                $("#password").focus();
                alert("请填写密码");
                return false;
            }
            Login();
        }

        $(document).ready(function () {
            $("#password").keydown(function (e) {
                var key = window.event ? e.keyCode : e.which;
                if (key == 13) {
                    $("#login_btn").click();
                    return false;
                }
            });
        });

        function Login() {
            $.ajax({
                type: "GET",
                url: "/Handler/Login.ashx",
                data: "name=" + $("#username").val() + "&psd=" + $("#password").val() + "&t=" + new Date(),
                beforeSend: function () {
                    $("#logTip").text("正在登录.......");
                },
                complete: function () {
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    $("#logTip").text("系统出错!");
                },
                success: function (data) {
                    if (data == 1) {
                        $("#logTip").text("用户名不存在!");
                    }
                    else if (data == 2) {
                        $("#logTip").text("密码错误!");
                    }
                    else {
                        location.href = "Index.aspx";
                        $("#logTip").text("");
                    }
                }
            });
            return false;
        }

        //取消重置
        function checkCancel() {
            var useraccount = document.getElementById("username");
            useraccount.value = "";

            var userpassword = document.getElementById("password");
            userpassword.value = "";

            return false;
        }

    </script>
</head>
<body>
    <form id="form1" runat="server">
    <table border="0" width="100%" height="100%">
        <tbody>
            <tr>
                <td valign="center" align="middle">
                    <table border="0" cellspacing="0" cellpadding="0" width="400" align="center">
                        <tbody>
                            <tr>
                                <td><img src="Images/kjgldl_01.gif" width="484" height="90"></td>
                            </tr>
                            <tr>
                                <td><img src="Images/kjgldl_02.gif" width="484" height="48"></td>
                            </tr>
                            <tr>
                                <td height="144" background="/Images/kjgldl_03.gif">
                                    <table border="0" cellspacing="0" cellpadding="0" width="44%" align="center">
                                        <tbody>
                                            <tr>
                                                <td height="31" width="42%">
                                                    <div align="right">
                                                        <strong><font color="#1c2d4e">用户名：&nbsp;</font></strong></div>
                                                </td>
                                                <td width="58%">
                                                    <input style="border-bottom: #494964 1px solid; border-left: #494964 1px solid; background-color: #ffffff;
                                                        border-top: #494964 1px solid; border-right: #494964 1px solid" id="username"  value="wesley"
                                                        size="18" name="username">
                                                </td>
                                            </tr>
                                            <tr>
                                                <td height="39">
                                                    <div align="right">
                                                        <strong><font color="#1c2d4e">密 码：&nbsp;</font></strong>
                                                    </div>
                                                </td>
                                                <td>
                                                    <input style="border-bottom: #494964 1px solid; border-left: #494964 1px solid; background-color: #ffffff;
                                                        border-top: #494964 1px solid; border-right: #494964 1px solid" id="password" value="wesley"
                                                        size="19" type="password" name="password">
                                                </td>
                                            </tr>
                                            <tr>
                                                <td height="43" colspan="2">
                                                    <div align="center">
                                                        <table border="0" cellspacing="0" cellpadding="0" width="127" align="right">
                                                            <tbody>
                                                                <tr>
                                                                    <td width="71">
                                                                        <input style="border-bottom: 0px; border-left: 0px; width: 55px; background: url(/Images/kjgldl_05.gif);
                                                                            height: 24px; border-top: 0px; cursor: pointer; border-right: 0px" id="login_btn"
                                                                            onclick="checkForm();" type="button">
                                                                    </td>
                                                                    <td width="59">
                                                                        <input style="border-bottom: 0px; border-left: 0px; width: 55px; background: url(/Images/kjgldl_06.gif);
                                                                            height: 24px; border-top: 0px; cursor: pointer; border-right: 0px" onclick="return checkCancel();"
                                                                            type="button">
                                                                    </td>
                                                                </tr>
                                                            </tbody>
                                                        </table>
                                                    </div>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td colspan="2">
                                                    <span style="color: Red" id="logTip"></span>
                                                </td>
                                            </tr>
                                        </tbody>
                                    </table>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <img src="/Images/kjgldl_04.gif" width="484" height="52">
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </td>
            </tr>
        </tbody>
    </table>
    </form>
</body>
</html>
